package com.ruige.data.aop;

import com.ruige.data.config.DataSourceContextHolder;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Aspect
@Component
@Order(100)
public class DatasourceAOP {

    @Pointcut("execution(* com.ruige.data.models.huapu.servcie..*.*(..)) || execution(* com.ruige.data.models.client.service..*.*(..))")
    public void huapuPointcut(){}

    @Pointcut("execution(* com.ruige.data.models.local.service..*.*(..))")
    public void localPointcut() {}



    @Before("huapuPointcut()")
    public void huapuDb() {
        DataSourceContextHolder.huapu();
    }


    @Before("localPointcut()")
    public void weiduDb() {
        DataSourceContextHolder.local();
    }

}
